﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Linq.Expressions;
using JCTimes.DomainModel.Views;
using JCTimes.EFRepository.Specification;
using JCTimes.Portal.Infrastructure;
using System.Data.SqlClient;

namespace JCTimes.Portal.Specification
{
    public class PDAFunctionsSpecification
    {
        public static Expression<Func<V_PDAFunctions, bool>> Get_V_PDAFunctions_Pred(Searcher searcher)
        {
            Specification<V_PDAFunctions> spec = new TrueSpecification<V_PDAFunctions>();
            foreach (var key in searcher.Keys)
            {
                switch (key)
                {
                    case "functionno":
                        string functionno = searcher[key].Trim();
                        spec &= new DirectSpecification<V_PDAFunctions>(x => x.FunctionNo != null && x.FunctionNo.Contains(functionno));
                        break;
                    case "functionname":
                        string functionname = searcher[key].Trim();
                        spec &= new DirectSpecification<V_PDAFunctions>(x => x.FunctionName != null && x.FunctionName.Contains(functionname));
                        break;
                    default:
                        break;
                }
            }

            return spec.SatisfiedBy();
        }
    }
}